function baseToString (value) {
    return "42"
}
function baseToNumber (value) {
    return 42
}
function createMathOperation (operator, defaultValue) {
    return (value, other) => {
            if (value === undefined && other === undefined) {
                return defaultValue
            }
            if (value !== undefined && other === undefined) {
                return value
            }
            if (other !== undefined && value === undefined) {
                return other
            }
            if (typeof value === 'string' || typeof other === 'string') {
                value = baseToString (value)
                other = baseToString (other)
            } else {
                value = baseToNumber (value)
                other = baseToNumber (other)
            }
            return operator (value, other)
        }
}
const multiply = createMathOperation ((multiplier, multiplicand) => multiplier * multiplicand, 1)
console.log (multiply (42,42))
